(function () {

    "use strict";

    $(document).ready(function() {
        if (!window.localStorage.getItem('shuangshi_kjson_12')) {
            window.localStorage.setItem("shuangshi_kjson_12", (new Date()).getTime());
            $('#shuangshi1Modal1').modal('show', 'center');
        } else {
            var lasttime = window.localStorage.getItem('shuangshi_kjson_12');
            var nowtime = new Date().getTime();
            if (nowtime - lasttime >= 1000 * 60 * 60 * 12) {
                window.localStorage.setItem("shuangshi_kjson_12", (new Date()).getTime());
                $('#shuangshi1Modal1').modal('show', 'center');
            }
        }

        var now_time = $(".now-time"),
                time1 = $(".time1"),
                time2date = $(".time2date"),
                time1_bj = $(".time1-bj"),
                time2 = $(".time2"),
                date2time = $(".date2time"),
                time2_bj = $(".time2-bj");

                var timestamptostr = function(timestamp) {
                    var d = new Date(timestamp * 1000);
                    var _d = (d.getFullYear()) + "-" + (d.getMonth() + 1) + "-" + (d.getDate()) + " " + (d.getHours()) + ":" + (d.getMinutes()) + ":" + (d.getSeconds());
                    return _d;
                };

                setInterval(function() {
                    now_time.val(Math.round(new Date().getTime() / 1000));
                },
                1000);
                time1.val(Math.round(new Date().getTime() / 1000));
                time2_bj.val(timestamptostr(Math.round(new Date().getTime() / 1000)));

                time2date.on("click",
                function() {
                    time1_bj.val(timestamptostr(time1.val()));
                });
                date2time.on("click",
                function() {
                    var t = time2_bj.val();
                    t = t.replace(/-/g, "/");
                    var d = new Date(t);
                    time2.val(d.getTime() / 1000);
                });

    });
})();

